package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.GoodsType;
import com.atguigu.jxc.service.GoodsTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
public class GoodsTypeController {
    @Autowired
    private GoodsTypeService goodsTypeService;


    @PostMapping("goodsType/loadGoodsType")
    public List loadGoodsType(){
        return  goodsTypeService.loadGoodsType();
    }
  // 获取所有的 商品单位
    @PostMapping("/unit/list")
    public Map<String,Object> getUnitList(){
       return goodsTypeService.getUnitList();
    }
    //新增分类
    @PostMapping("/goodsType/save")
    public  ServiceVO save(String  goodsTypeName,Integer  pId){
        goodsTypeService.save(goodsTypeName,pId);
        return new ServiceVO(100,"请求成功",null);
    }
    //删除分类
    @PostMapping("/goodsType/delete")
    public ServiceVO delete(Integer  goodsTypeId){
     goodsTypeService.delete(goodsTypeId);
     return new ServiceVO(100,"请求成功",null);
    }

}
